home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / bbs / fax_it_cnet.lzh / FAX-IT / USRobotics_Users / autofax.gpf next >
Text File  |  1994-09-10  |  6KB  |  210 lines

  1. /* This is the program that converts the FAX TEXT into a FAX 
  2.  * then tries to send it out.
  3.  *
  4.  * First we'll kill trapdoor:
  5.  */
  6. address command "cd mail:bin/"  
  7. address command "Traptell quit"
  8. address REXX_GPFAX LISTEN
  9.  
  10. /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  11.  * AutoFAX has no information for you as the sysop to edit
  12.  *
  13.  * Go change the FAX-Times file and leave everything below here alone...
  14.  * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  15.  */
  16.  
  17.  
  18. options results
  19.  
  20. /* Check to be sure GPFax is even running.... 
  21.  */
  22. if show(prorts,REXX_GPFAX) ~= 1 then exit
  23.  
  24. Version='FAX-IT v2.5   -*-   AutoFAX v2.5   -*-   By: Glenn J. Schworak'
  25.  
  26. Address cnetRexx0
  27. GetUser 1307954 ; UserDir = Result
  28. Doors   = 'Doors:' ; GPF = 'Doors:Fax-IT/'
  29. LogFAX = 'Logs:FAX.log'
  30. FaxIT         = Doors'Fax-IT/'
  31. Times         = FaxIT'FAX-Times'
  32. Messages  = FaxIT'Text/'
  33. Numbers   = FaxIT'Numbers/'
  34.  
  35.  
  36. /* As in the DataCall.gpf file, we set a file in the T: directory to keep
  37.  * any other FAX-IT programs from trying to access GPFax while we are
  38.  * working
  39.  */
  40. Shell Command 'C:Echo >t:FAXnode ""'
  41.  
  42.  
  43.  
  44.  
  45. /*
  46.  * Edit the file "FAX-Times" to configure the correct times for your
  47.  * FAX modem to attempt to dial. These times will not stop a user from
  48.  * typing a FAX message, just keep the system from calling out right away.
  49.  */
  50.  
  51. stat=Exists(Times)
  52. if stat~=1 then do
  53.     address command 'Echo >>'LogFAX' "b1c1ERROR: c6The c3FAX-Times c6file is missing from the FAX-IT door area...w2q1"'
  54.     exit
  55. end
  56. Open(tempfile,Times,'read') 
  57.     hours=readln(tempfile)
  58.     days=readln(tempfile)    
  59. Close(tempfile)
  60.  
  61.  
  62. Now = '-'Time('Hours')'-'
  63. Day = SubStr(Date('W'),1,3)
  64.  
  65.  
  66. Force="*"
  67. stat=Exists("T:FAX-NOW") 
  68. if stat=1 then do
  69.     Open(tempfile,"T:FAX-NOW",'read') 
  70.         Force=readln(tempfile)
  71.     Close(tempfile)
  72.     Shell Command "C:Delete T:FAX-NOW"
  73. end
  74.  
  75.  
  76. Open(tempfile,'T:TryFAX','write') ; Close(tempfile)
  77.  
  78. Do While Exists('T:TryFAX')='1'
  79.     Address Command 'c:Delete t:TryFAX'
  80.     if Force="*" then do
  81.         If Index(Hours,Now)=0 | Index(Days,Day)=0 Then Call Quit
  82.         Address Command 'c:List >T:FAX-List 'Messages'GJSFAX#?.#? Lformat "%S"'
  83.         end
  84.     else do
  85.         Address Command 'C:Echo >T:FAX-List 'Force
  86.     end
  87.     Address rexx_gpfax
  88.  
  89.     File = Open(ListFile,'T:FAX-List','READ')
  90.     If File~=1 Then Call Quit
  91.  
  92.     Do Until EOF(ListFile)
  93.         TextFile = ReadLN(ListFile)
  94.         convert Messages||TextFile
  95.           File = Open(Text,Messages||TextFile,'READ')
  96.           if File=1 Then do
  97.          FAXNUM = ReadLN(Text)
  98.          txt=''
  99.           FAXed='FAXed Out: 'Time('Civil')'  'Date('Normal')
  100.           do while Index(txt,"TO:")<1      
  101.             txt = ReadLN(Text)
  102.          end
  103.           TO='       'Strip(txt)
  104.        do while Index(txt,"FAX:")<1     
  105.           txt = ReadLN(Text) 
  106.        end
  107.           FAX='      'Strip(txt)
  108.        do while Index(txt,"SUBJECT:")<1 
  109.           txt = ReadLN(Text) 
  110.        end
  111.           Subject='  'Strip(txt)
  112.        do while Index(txt,"FROM:")<1    
  113.           txt = ReadLN(Text) 
  114.        end
  115.         FROM2=txt 
  116.        UserNum=Strip(SubStr(txt'          ',Index(txt,#)+1,10))
  117.        do while Index(txt,"WRITTEN:")<1 
  118.           txt = ReadLN(Text) 
  119.        end
  120.           Written='  'Strip(txt)
  121.        Close(Text)
  122.           SendF = 'GPFax:FAX_OUT/'TextFile'_TFAX'
  123.        SendFAX SendF' to 'Compress(FAXNUM)
  124.           Stat=''
  125.           ReportLog T 3
  126.           Stat=result
  127.           File2 = open(StatFile,UserDir'FaxStatus','Append')
  128.           if File2 = 0 then File2 = open(StatFile,UserDir'FaxStatus','Write')
  129.        if SubStr(Stat,1,4)='OK.S' then do
  130.          if File2 = 1 then call FAXGOOD
  131.          end 
  132.        else do
  133.             if File2 = 1 then Call FAXBAD
  134.          address command 'c:copy 'Messages||TextFile' to 'UserDir
  135.        end
  136.        if File2 = 1 then do
  137.             WriteLN(StatFile,'02}n1k4-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-q1')
  138.          end
  139.          if File2 = 1 then Close(StatFile)
  140.       end 
  141.       address command 'c:delete >NIL: 'Messages||TextFile
  142.     end 
  143.   Close(ListFile)
  144.  
  145.   address command 'c:delete GPFax:FAX_OUT/GJSFAX#?.p#?'
  146.   address command 'c:delete T:FAXnode'
  147. end
  148. call Quit
  149.  
  150.  
  151. Quit:
  152.   address command 'c:delete t:#?FAX#?'
  153.  
  154.  /* Now we'll bring up TrapDoor and tell GPFax to go to sleep again */
  155.  
  156.   address command "run >nil: <nil: trapdoor"
  157.   address REXX_GPFAX UNLISTEN
  158.  
  159.  exit
  160.  
  161.  
  162. FAXGOOD:
  163.   If ~Exists(Numbers||FAXNUM) then do
  164.       open(NumFile,Numbers||FAXNUM,'Write')
  165.       WriteLN(NumFile,'k1---k0c1 NUMBER IS UNKNOWN TO THIS SYSTEMk1 ---k0q1')
  166.       close(NumFile)
  167.   end
  168.   WriteLN(StatFile,'n3c3This FAX was successfully sent....   'FAXed)
  169.   WriteLN(StatFile,'n1c2'TO'n1'FAX'n1'Subject'n1'Written)
  170.   call StartFile
  171.   open(LogFile,LogFAX,'Append')
  172.   WriteLN(LogFile,'n2c2---SUCCESSFUL---n1q1  'From2'n1'TO'n1'FAX'n1'Subject'n1'Written)
  173.   numf=open(NumFile,Numbers||FAXNUM,'Read')
  174.   if numf=1 then do
  175.     Pre='     NOTE:c6 '
  176.     do while ~eof(numfile)
  177.         txt=ReadLN(numfile)
  178.        WriteLN(StatFile,Pre||txt)
  179.        WriteLN(LogFile,Pre||txt)
  180.         Pre='           '
  181.     end
  182.     close(numfile)
  183.   end
  184.   close(LogFile)
  185.   Return
  186.  
  187.  
  188. FAXBAD:
  189.   WriteLN(StatFile,'n3c3This FAX failed to send....  'time('civil'))
  190.   WriteLN(StatFile,'n1c1'TO'n1'FAX'n1'Subject'n1'Written'n2')
  191.   WriteLN(StatFile,'--FAILED--')
  192.   WriteLN(StatFile,TextFile)
  193.   open(LogFile,LogFAX,'Append')
  194.   WriteLN(LogFile,'n2c1---FAILED---n1q1  'From2'n1'TO'n1'FAX'n1'Subject'n1'Written)
  195.   close(LogFile)
  196.   Return
  197.  
  198.  
  199. StartFile:
  200.     if ~exists(LogFAX) then do
  201.         open(LogFile,LogFAX,'Write')
  202.         WriteLN(LogFile,'f1q1'Version'n2Started: 'Date(n)'  -*-  'Time(c)'n2')
  203.         close(LogFile)
  204.     end
  205.     return
  206.     
  207.  
  208. Quit:
  209.     exit
  210.